var tantan_number_lv = 1;
var tantan_html_lv = '';
var x;
var y;
var y1;
var this_tantan;

function tantan_duang_lv() {
	for(tantan_number_lv; tantan_number_lv < 3; tantan_number_lv++) {
		tantan_html_lv += '<li>';
		tantan_html_lv += '<div class="tantan_duang_img_lv">';
		tantan_html_lv += '<img src="http://ftp.tj.dyrs.com.cn/yd/case/anli' + tantan_number_lv + '/images/case1.jpg" />';
		tantan_html_lv += '</div>';
		tantan_html_lv += '<div class="tantan_duang_button_lv">';
		tantan_html_lv += '<a tap_lv=-1>不喜欢</a>';
		tantan_html_lv += '<a tap_lv=1>喜欢</a>';
		tantan_html_lv += '</div>';
		tantan_html_lv += '</li>';
	}
	$('.tantan_duang_lv').html(tantan_html_lv);
}

function tantan_duang_lv2() {
	tantan_number_lv2 = (tantan_number_lv - -1);
	tantan_html_lv = '';
	for(tantan_number_lv; tantan_number_lv < tantan_number_lv2; tantan_number_lv++) {
		tantan_html_lv += '<li>';
		tantan_html_lv += '<div class="tantan_duang_img_lv">';
		tantan_html_lv += '<img src="http://ftp.tj.dyrs.com.cn/yd/case/anli' + tantan_number_lv + '/images/case1.jpg" />';
		tantan_html_lv += '</div>';
		tantan_html_lv += '<div class="tantan_duang_button_lv">';
		tantan_html_lv += '<a tap_lv=-1>不喜欢</a>';
		tantan_html_lv += '<a tap_lv=1>喜欢</a>';
		tantan_html_lv += '</div>';
		tantan_html_lv += '</li>';
		if(tantan_number_lv < 47) {
			$('.tantan_duang_lv').prepend(tantan_html_lv);
		}
	}
}
$(document).on('touchstart', '.tantan_duang_lv li', function(e) {
	var touch = e.touches[0];
	x1 = parseInt(touch.pageX);
	y1 = parseInt(touch.pageY);

});
$(document).on('touchmove', '.tantan_duang_lv li', function(e) {
	this_tantan = $(this);
	var touch = e.touches[0];
	x = parseInt(touch.pageX) - (x1 - 60);
	y = parseInt(touch.pageY) - (y1 - 100);
	$(this).css({
		left: x,
		top: y
	});
});
$(document).on('touchend', 'body', function(e) {
	if(x < 20) {
		$(this_tantan).animate({
			left: '-150%',
			top: y
		}, 500, 'ease');
	} else if(x > 90) {
		$(this_tantan).animate({
			left: '150%',
			top: y
		}, 500, 'ease');
	} else {
		$(this_tantan).animate({
			left: '15%',
			top: '100px'
		}, 500, 'ease');
	}
	tantan_duang_lv2();
});
$(document).on('tap', '.tantan_duang_lv li .tantan_duang_button_lv a', function() {
	var this_tap_lv = $(this).attr("tap_lv");
	$(this).parents("li").animate({
		left: this_tap_lv * 150 + '%'
	}, 500, 'ease');
	tantan_duang_lv2();
});